#include <cstdio>
#include <algorithm>

using namespace std;

int N = 0, L = 0, H = 0;
int pass = 0;
//学生
struct stu{
    int id; //学号
    int d;  //德分
    int c;  //才分
    int sum;    //总分
    int level;  //阶梯
    
    bool operator <(const stu& that) const{
        if(level != that.level) { return level < that.level; }
        if(sum == that.sum){
            if(d != that.d ) { return d > that.d; }
            if(id != that.id ) { return id < that.id; }
        }
        return sum > that.sum;
    }
    void init(){
        sum = d + c;
        //第一阶梯    德才分都过H
        if(c >= H && d >= H){
            level = 0;
        }
        //第二阶梯   才分未到H，德分到H
        else if(c >= L && c < H && d >= H){
            level = 1;
        }
        //第三阶梯   均未到H，同时德分不低于才分
        else if(c >= L && c < H && d >= L && d < H && d >= c){
            level = 2;
        }
        //第四阶梯   均过L
        else if(c >= L && d >= L){
            level = 3;
        }
        //不及格
        else{
            pass--;
            level = 4;
            
        }
    }
    void print(){
        if(d < L || c < L){ return; }
        printf("%08d %d %d\n", id, d, c);
    }
}stu[100005];

int main()
{
    scanf("%d %d %d", &N, &L, &H);
    pass = N;
    for(int i = 0; i < N; i++){
        scanf("%d %d %d", &stu[i].id,  &stu[i].d,  &stu[i].c);
        stu[i].init();
    }
    sort(stu, stu+N);
    printf("%d\n", pass);
    for(int i = 0; i < N; i++){
        stu[i].print();
    }
    return 0;
}
